package ModelLayer;
import java.util.*;
/**
 * Write a description of class CustomerList here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class CustomerList
{
    // instance variables - replace the example below with your own
    private HashMap<Integer, Customer> allCustomers;
    private static CustomerList instance = null;
    /**
     * Constructor for objects of class CustomerList
     */
    public CustomerList()
    {
        // initialise instance variables
        allCustomers = new HashMap<Integer, Customer>();
    }

    public static CustomerList getInstance() { 
        if(instance == null) 
            instance = new CustomerList(); 
        return instance; 
    }

    public void addCustomer(Customer customer) {
        allCustomers.put((Integer)customer.getId(), customer);
    }

    public boolean deleteCustomer(int id) 
    {
       return (allCustomers.remove(id)!=null);
    }

    public Customer getCustomer(int id) {
        if(allCustomers.containsKey(id)) {
            return allCustomers.get(id);
        }
        return null;
    }
 
    
    public Iterator getCustomersIterator() { return allCustomers.values().iterator(); }
    public int getCustomerSize() { return allCustomers.size(); }
}
